package com.atguigu.statistics.schedule;


import com.atguigu.statistics.service.StatisticsDailyService;
import com.atguigu.statistics.utils.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class ScheduledTask {

    @Autowired
    private StatisticsDailyService statisticsDailyService;
    //"0/5 * * * *?": 每隔5秒执行一次这个方法
    //"0 0 1 * * ?" :每天的1点执行一次   7字表达式在idea只能有6位
    @Scheduled(cron = "0 0 1 * * ?")
    public void task1(){
        statisticsDailyService.registerCount(DateUtil.formatDate(DateUtil.addDays(new Date(),-1)));
    }




}
